<template>
	<view>
		地区列表
		<uni-search-bar @input="delaygetarealist" v-model="searchkey"></uni-search-bar>
		<!-- <uni-easyinput @input="easyinput" v-model="inputdata"></uni-easyinput> -->
		<view style="height: 80vh; overflow-y: auto;">
			<cc-wxBtn v-for="(item,index) in areainfo" :key="index"
				:title="item.province+','+item.city+','+item.country" @menuClick="areaselectsubmit(item)"></cc-wxBtn>
		</view>
	</view>
</template>

<script>
	import {
		postrequest
	} from '../../common/apis.js';
	export default {
		name: "arealist",
		data() {
			return {
				inputdata: '',
				searchkey: '',
				delaytimer: '',
				areainfo: ''
			};
		},
		mounted() {
			this.getarealist()
		},
		methods: {
			easyinput() {
				this.$forceUpdate()
				clearTimeout(this.delaytimer)
				this.delaytimer = setTimeout(() => {
					console.log(this.inputdata)
				}, 100)
			},
			areaselectsubmit(item) {
				this.$emit('areaselectsubmit', item)
			},
			delaygetarealist() {
				clearTimeout(this.delaytimer)
				this.delaytimer = setTimeout(() => {
					this.getarealist()
				}, 1000)
			},
			getarealist() {
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					searchkey: this.searchkey
				}
				let url = 'https://www.jsyufang.com/yixun/api/getarealist/index.asp'
				let errmessage = '获取地区列表接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						console.log(res.data.data)
						this.areainfo = res.data.data
					})
			}
		}
	}
</script>

<style>

</style>